﻿<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('@ID("#txt_avatarFile")').autocomplete({
            source: function (request, response) {
                jQuery.post('@Html.Raw(Url.Action(Loc.Act("Autocomplete").Ctrl("File").Area("FileSystem")))', request, response);
            },
            minLength: 3,
            select: function (event, ui) {
                jQuery('@ID("#hidden_avatarFile")').val(ui.item.id);
            }
        });
    });
</script>
<form id="@ID("form")" action="@Url.Action(Loc.Act("Update").Ctrl("Member"))" method="post">
    <input type="hidden" name="flags" value="None" />
    <table>
        <tr>
            <td>
                <label>#</label>
            </td>
            <td>
                <input type="text" readonly name="id" value="@JDM.Int32(Model.EntityID)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>&#10001;</label>
            </td>
            <td>
            <input type="text" readonly value="@Svc.DateTime((DateTime)JDM.DateTime(Model.CreatedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>&#10002;</label>
            </td>
            <td>
            <input type="text" readonly value="@Svc.DateTime((DateTime)JDM.DateTime(Model.UpdatedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                @if(Model.Rank != null)
                {
                    <a href="@Url.Action(Loc.Act("Edit").Ctrl("Rank").Set(new
                    {
                        id = JDM.Int32(Model.Rank.EntityID)
                    }))" class="ui-icon ui-icon-extlink"></a>
                }
                <label>@T(Res.Name("Rank"))</label>
            </td>
            <td>
                @{
                    var t_rank = Model.Rank == null ? null : (Model.Rank.Translations as IEnumerable<dynamic>)
                        .SingleOrDefault(x => JDM.Int32(x.Language.EntityID) ==
                            JDM.Int32(Svc.Localization.Language.EntityID));
                    <input type="text" readonly value="@(t_rank != null ? JDM.String(t_rank.Name) : (Model.Rank != null ? JDM.Int32(Model.Rank.EntityID) : 0))" />
                }
            </td>
        </tr>
        <tr>
            <td>
                @if(Model.AvatarFile != null)
                {
                    <a href="@Url.Action(Loc.Act("Edit").Ctrl("File").Area("FileSystem").Set(new
                    {
                        id = JDM.Int32(Model.AvatarFile.EntityID)
                    }))" class="ui-icon ui-icon-extlink"></a>
                }
                <label>@T(Res.Name("Avatar"))</label>
            </td>
            <td>
                <input id="@ID("hidden_avatarFile")" type="hidden" name="avatarFileID" value="@(Model.AvatarFile != null ? JDM.Int32(Model.AvatarFile.EntityID) : 0)" />
                <input id="@ID("txt_avatarFile")" type="text" value="@(Model.AvatarFile != null ? JDM.String(Model.AvatarFile.Name) : String.Empty)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Signature"))</label>
            </td>
            <td>
                <textarea name="signature">@JDM.String(Model.Signature)</textarea>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("TopicCount"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.Int32(Model.TopicCount)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("PostCount"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.Int32(Model.PostCount)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("KarmaPoints"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.Int32(Model.KarmaPoints)" />
            </td>
        </tr>
        <tr>
            <td>
                <a href="@Url.Action(Loc.Act("Edit").Ctrl("Account").Area("Membership").Set(new
                {
                    id = JDM.Int32(Model.Account.EntityID)
                }))" class="ui-icon ui-icon-extlink"></a>
                <label>@T(Res.Name("Account"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.String(Model.Account.Email)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("ForumMemberFlags").Name("Active"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" value="Active" @(JDM.HasFlags(Model.Flags, "Active") ? "checked" : String.Empty) />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>